<?php

namespace App\Http\Controllers\Education;

use App\Common\Utils\JsonResponse;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class HeadMasterController extends Controller
{
    /** @var \App\Services\System\LogService $logService */
    private $logService;
    /** @var \App\Services\Education\HeadMasterService $headMasterService */
    private $headMasterService;

    /**
    * Create a new controller instance.
    *
    * @return void
    */
    public function __construct()
    {
        parent::__construct();
        $this->middleware('auth');
        $this->logService = app('logService');
        $this->headMasterService = app('headMasterService');
    }

    /**
     * @Description: 获取班主任列表信息数据
     * @Author: kzj
     * @datetime: 2023-02-21
     */
    public function getList(Request $request)
    {
        try
        {
            $result = $this->headMasterService->getList($request->all());
            $this->logService->log('262', '班主任查看', '班主任查看');
            return JsonResponse::get($result['data'], TRUE, $result['total'], $result['per_page']);
        }
        catch(\Exception $e)
        {
            return $this->error($e);
        }
    }

    /**
     * @Description: 班主任添加
     * @Author: kzj
     * @datetime: 2023-02-28
     */
    public function add(Request $request)
    {
        try{
            $result = $this->headMasterService->add($request->all());
            $this->logService->log('263', '班主任添加', '班主任添加');
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * @Description: 班主任单条数据
     * @Author: kzj
     * @datetime: 2023-02-28
     */
    public function one(Request $request)
    {
        try{
            $result = $this->headMasterService->one($request->all());
            $this->logService->log('229', '课题研究上传', '课题研究上传');
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * @Description: 班主任编辑
     * @Author: kzj
     * @datetime: 2023-02-28
     */
    public function edit(Request $request)
    {
        try{
            $result = $this->headMasterService->edit($request->all());
            $this->logService->log('264', '班主任编辑', '班主任编辑');
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * @Description: 班主任删除
     * @Author: kzj
     * @datetime: 2023-02-28
     */
    public function del(Request $request)
    {
        try{
            $result = $this->headMasterService->del($request->all());
            $this->logService->log('266', '班主任删除', '班主任删除');
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /*
     * @Description: 班主任导出
     * @Author:  Kzj
     * @Date: 2023-11-17 14:43:04
     */
    public function export(Request $request)
    {
        try{
            $result = $this->headMasterService->export($request->all());
            $this->logService->log('344', '班主任导出', '班主任导出');
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }

    /**
     * @Description: 班主任审核
     * @Author: qiankun
     * @datetime: 2025-03-26
     */
    public function check(Request $request)
    {
        try{
            $result = $this->headMasterService->check($request->all());
            $this->logService->log('212', '班主任审核', '班主任审核');
            return JsonResponse::success($result,'操作成功');
        }catch(\Exception $e){
            return JsonResponse::error($e->getMessage());
        }
    }
}
